package cn.itcast.hotel.mq;

import cn.itcast.hotel.service.IHotelService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 监听器
 */
@Component
public class HotelListener {
    @Autowired
    private IHotelService hotelService;

    /**
     * 监听 删除操作
     * @param id
     */
    @RabbitListener(queues = MqConstant.HOTEL_DELETE_QUEUE)
    public void deleteById(Long id) {
        hotelService.deleteById(id);
    }

    /**
     * 监听 插入操作
     * @param id
     */
    @RabbitListener(queues = MqConstant.HOTEL_INSERT_QUEUE)
    public void insertById(Long id) {
        hotelService.insertById(id);
    }

}
